package cn.zh.npro.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;

import cn.zh.npro.Adapter.RpAdapter;
import cn.zh.npro.Item.RpItem;
import cn.zh.npro.R;
import cn.zh.npro.Util.ToastUtil;

public class DeOrder extends BaseActivity {
    ArrayList<RpItem> tlist;
    ImageView back;
    RpAdapter rpAdapter=null;
    ListView pulist;

    TextView total,look,empty;
    String type="",cid="";
    View popview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_de_order);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        type=getIntent().getStringExtra("type");
        tlist= (ArrayList<RpItem>) getIntent().getSerializableExtra("tlist");
        cid=getIntent().getStringExtra("customerID");
        initdo();

        }

       public void initdo(){
           back=findViewById(R.id.back);
           total=findViewById(R.id.total);
           look=findViewById(R.id.look);
           popview=findViewById(R.id.popview);
           empty= (TextView)findViewById(R.id.empty);
           pulist= (ListView) findViewById(R.id.pulist);
           View view=findViewById(R.id.activity_de_order);
           rpAdapter=new RpAdapter(DeOrder.this,tlist,total,1,view,popview,cid);
           pulist.setAdapter(rpAdapter);
           back.setOnClickListener(this);
           look.setOnClickListener(this);
           }


    @Override
    public void onClick(View view) {
        super.onClick(view);
        int id=view.getId();
        switch (id){
            case R.id.back:
                finish();
                break;
            case R.id.look:
                if (tlist.size()==0){
                    ToastUtil.showLong(DeOrder.this,"请选择商品");
                    finish();
                    return;
                  }
                Intent intent=new Intent(DeOrder.this,Order.class);
                intent.putExtra("tlist",tlist);
                intent.putExtra("type",type);
                intent.putExtra("customerID",cid);
                startActivity(intent);
                break;
           }
        }
  }
